<?php

class recibos extends Baserecibos
{
   public function __toString()
      {
         return $this->getNumeropago();
      }
   public static function getTotalPagado($recibos_id){
       $c = Propel::getConnection();
       //Select Sum(importe) as Suma from '. recibosportipovalorPeer::TABLE_NAME.' where '. recibosportipovalorPeer::RECIBOS_ID.
       $consulta = 'Select Sum(importe) as Suma From recibosportipovalor where recibos_id  = '. $recibos_id;
       $sentencia = $c->prepare($consulta);
       $sentencia->execute();
       $row = $sentencia->fetch();
       $total = $row['Suma'];
       return $total;
   }
   /*private function SumRecibo(){
       $factura = facturasPeer::retrieveByPK($this->getFacturasId());
       $factura->setTotalPagado($factura->getTotalPagado() + $this->getMonto());
       $factura->save();
   }
   private function RestarRecibo(){
       $factura = facturasPeer::retrieveByPK($this->getFacturasId());
       $factura->setTotalPagado($factura->getTotalPagado() - $this->getMonto());
       $factura->save();
   }*/
   public function save(PropelPDO $con = null){
      // $this->SumRecibo();
       return parent::save();
   }
   public function delete(PropelPDO $con = null){
       //$this->RestarRecibo();
       return parent::delete($con);
   }
}
